package cn.i7baozh.cloud.consumer.feign.controller;

import cn.hutool.core.date.DateTime;
import cn.i7baozh.cloud.api.dto.PayDTO;
import cn.i7baozh.cloud.api.dto.ReturnResponse;
import cn.i7baozh.cloud.consumer.feign.service.RemotePayService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author zhangbaoqi532
 * @date 2024/12/25
 */
@Slf4j
@RestController
public class ConsumerController {

    @Resource
    private RemotePayService remotePayService;

    @GetMapping(value = "/consumer/get/{id}")
    public ReturnResponse<PayDTO> get(@PathVariable("id") Integer id) {
        log.info("请求开始 {}", DateTime.now());
        ReturnResponse<PayDTO> dto = null;
        try{
            dto =  remotePayService.get(id);
        } catch (Exception e) {
            e.printStackTrace();
        }
        log.info("请求结束 {}", DateTime.now());
        return dto;
    }

    @GetMapping(value = "/consumer/getServerInfo")
    public ReturnResponse<String> getServerInfo() {
        return remotePayService.getServerInfo();
    }

}
